[id].vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. <template>
  2. <div>
  3. <!-- 页面头部 -->
  4. <HomePageHead></HomePageHead>
  5. <HomePageNavigation1></HomePageNavigation1>
  6. <!-- 商圈详情 -->
  7. <div class="topicInfoBox">
  8. <div class="inner">
  9. <!-- 详情头部 -->
  10. <div class="infoHead">
  11. <div class="left">
  12. <div class="userInfo left">
  13. <el-badge value="楼主" class="item" type="warning">
  14. <img v-if='dataInfo.avatar' :src="dataInfo.avatar" alt="">
  15. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png' alt="">
  16. </el-badge>
  17. <span>{{ dataInfo.author }}</span>
  18. </div>
  19. <div class="headContent left">
  20. <h2>{{ dataInfo.title }}</h2>
  21. <p v-show="dataInfo.group_name">
  22. 群聊:
  23. <span>{{ dataInfo.group_name }}</span>
  24. <button @click="joinGroup">加入群聊</button>
  25. </p>
  26. </div>
  27. </div>
  28. <div class="right">
  29. <div class="one">
  30. <span v-for="item in typeList" :key="index">
  31. <span v-if="dataInfo.type == item.value" class="one">{{item.label}}</span>
  32. </span>
  33. </div>
  34. <p>{{ dataInfo.updated_at }}</p>
  35. </div>
  36. </div>
  37. <!-- 详情页 文本+图片 -->
  38. <div class="infoContent" v-show="dataInfo.content">
  39. <div v-html="dataInfo.content"></div>
  40. </div>
  41. <div class="infoContent1" v-show="!dataInfo.content">
  42. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Document_empty.png" alt="">
  43. <span>可以看看大家的互动哦~</span>
  44. </div>
  45. <!-- 详情页评论 -->
  46. <div class="comment">
  47. <h3>评论</h3>
  48. <div class="commentList" v-for="item in replyList" v-show="page_total != 0">
  49. <div class="left">
  50. <img v-if='item.avatar' :src="item.avatar" alt="" >
  51. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png' alt="">
  52. <span class="name">{{ item.author }} : </span>
  53. </div>
  54. <div class="center">
  55. <span class="context">{{ item.content }}</span>
  56. </div>
  57. <div class="right">
  58. <span class="time">{{ item.created_at }}</span>
  59. <!-- <span>回复</span> -->
  60. </div>
  61. </div>
  62. <div class="comment_empty" v-show="page_total == 0">
  63. <img src="../../public/topic/message_empty.png" alt="">
  64. <span>暂无评论</span>
  65. </div>
  66. </div>
  67. <!-- 分页 -->
  68. <div class="paginationBox" v-show="page_total != 0">
  69. <el-pagination background layout="prev, pager, next" :total="page_total" prev-text="上一页"
  70. next-text="下一页" :default-page-size="pageSize" @change="changePage" />
  71. </div>
  72. </div>
  73. </div>
  74. <div class="message">
  75. <div class="inner">
  76. <input v-model="content" placeholder="快来回复吧~" type="text" class="messageInput">
  77. <button class="btn" @click="addReply">确定</button>
  78. </div>
  79. </div>
  80. <!-- 页面底部 -->
  81. <HomeFoot1></HomeFoot1>
  82. </div>
  83. </template>
  84. <script setup>
  85. //1.引用模块 start ---------------------------------------->
  86. //使用ref和reactive动态变量
  87. import { ref, reactive, onMounted } from 'vue'
  88. import { useRoute } from 'vue-router';
  89. //使用官方ssr请求模块
  90. import { useNuxtApp, useFetch } from '#app'
  91. //使用element-plus组件
  92. import { ElPagination, ElBadge, ElInput, ElMessage, ElMessageBox } from 'element-plus';
  93. // axios请求
  94. const nuxtApp = useNuxtApp();
  95. const axios = nuxtApp.$axios;
  96. const { $webUrl, $CwebUrl, $BwebUrl } = useNuxtApp()
  97. //1.引用模块 end ---------------------------------------->
  98. // 定义响应式数据
  99. const seoData = ref({
  100. title: '商圈',
  101. description: '默认描述',
  102. keywords: '默认关键词',
  103. image: 'https://example.com/default-image.jpg'
  104. });
  105. // 在 onMounted 钩子中获取数据
  106. onMounted(()=>{
  107. seoData.value.title = '商圈';
  108. seoData.value.description = '默认描述';
  109. seoData.value.keywords = '默认关键词';
  110. })
  111. //2.页面数据 start ---------------------------------------->
  112. const dataInfo = ref({})
  113. const groupId = useState("groupId", () => '')
  114. const replyList = useState("replyList", () => []) //评论列表
  115. //分页
  116. const page = ref(1)
  117. const pageSize = ref(5)
  118. let page_total = ref(0)
  119. const content = ref('')
  120. //2.页面数据 end ---------------------------------------->
  121. //3.获取商圈详情 start ---------------------------------------->
  122. const route = useRoute();
  123. const id = route.params.id; // 获取传递的 id 参数
  124. //页码发生改变
  125. const changePage = (val) => {
  126. console.log(val);
  127. page.value = val
  128. getTopicReply()
  129. }
  130. // 商圈信息
  131. const getTopicInfo = () => {
  132. let data = new FormData()
  133. data.append('id', id)
  134. axios.post('chat/getTopicInfo', data).then(res => {
  135. console.log('商圈信息', res);
  136. dataInfo.value = res.data
  137. groupId.value = res.data.group_id
  138. console.log(groupId.value);
  139. })
  140. }
  141. // 回复商圈 列表
  142. const getTopicReply = () => {
  143. let data = new FormData()
  144. data.append('id', id)
  145. data.append('page', page.value)
  146. data.append('page_size', pageSize.value)
  147. axios.post('chat/getTopicReply', data).then(res => {
  148. console.log('回复商圈列表 ', res);
  149. replyList.value = res.data.data
  150. // page_total.value = res.data.total
  151. page_total.value = res.data.total
  152. console.log("replyList", replyList);
  153. })
  154. }
  155. //5.获取分类和状态 start ---------------------------------------->
  156. const listData = useState("listData", () => [])//商圈列表
  157. const typeList = useState("typeList", () => [])//商圈分类
  158. const topicType = () => {
  159. axios.post('/chat/topicType').then(response => {
  160. console.log(111222333)
  161. console.log(response.data);
  162. // console.log(1);
  163. typeList.value = response.data;
  164. })
  165. }
  166. const topicStatus = () => {
  167. axios.post('chat/topicStatus').then(response => {
  168. console.log(response);
  169. })
  170. }
  171. onMounted(() => {
  172. getTopicInfo(); //商圈信息
  173. getTopicReply(); //回复商圈列表
  174. topicType();
  175. topicStatus();
  176. })
  177. //加入群聊
  178. const joinGroup = () => {
  179. ElMessageBox.confirm(
  180. '加入群聊后,页面跳转至后台群聊页面',
  181. '是否加入群聊?',
  182. {
  183. confirmButtonText: '是',
  184. cancelButtonText: '否',
  185. center: true,
  186. }
  187. ).then(() => {
  188. console.log('groupId.value', groupId.value);
  189. let data = new FormData()
  190. data.append('group_id', groupId.value)
  191. axios.post('chat/joinGroup', data).then(res => {
  192. console.log('加入群聊 ', res);
  193. if (res.code == 0 && res.message !== '已加入群') {
  194. ElMessage.error(res.message)
  195. } else if (res.code == 0 && res.message == '已加入群') {
  196. ElMessage({
  197. message: res.message,
  198. type: 'success',
  199. })
  200. setTimeout(() => {
  201. window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  202. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  203. }, 1000)
  204. } else if (res.code == 200) {
  205. ElMessage({
  206. message: '加入成功',
  207. type: 'success',
  208. })
  209. setTimeout(() => {
  210. window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  211. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  212. }, 1000)
  213. }
  214. })
  215. }).catch(() => {
  216. ElMessage({
  217. type: 'error',
  218. message: '已取消',
  219. })
  220. })
  221. }
  222. // 回复商圈
  223. const addReply = () => {
  224. let data = new FormData()
  225. data.append('id', id)
  226. data.append('content', content.value)
  227. axios.post('chat/addReply', data).then(res => {
  228. console.log('回复商圈 ', res);
  229. if (res.code == 0) {
  230. ElMessage.error(res.message)
  231. getTopicReply();
  232. } else if (res.code == 200) {
  233. ElMessage({
  234. message: '回复成功',
  235. type: 'success',
  236. })
  237. content.value = ''
  238. getTopicReply();
  239. }
  240. })
  241. }
  242. //3.获取商圈详情 end ---------------------------------------->
  243. //seo
  244. useSeoMeta({
  245. title: "商圈" + "_" + "三农资讯网_全国政务信息一体化应用平台",
  246. meta: [
  247. { name: 'description', content: "三农资讯网以服务于党和国家各级职能部门三农政务资讯发布及政务公开信息公示为基点,为全国县级以上各级党政机关及其职能部门配置各自公开独立网络发布平台。主要频道有:三农政务资讯,农科资讯,农资购销,农产购销,农贸资讯,三农致富信息,农村文化生活,三农政策法规,三农之窗,三农调查,三农服务,三农知识,农民工,打假维权等。三农资讯网打造最具影响力的三农信息发布平台,并成为最具权威的三农资讯网。_三农资讯网-测试专用_全国政务信息一体化应用平台" , tagPriority: 10 },
  248. { name: 'keywords', content: "三农资讯,农业,三农,三农在线,农业新闻,三农资讯网_三农资讯网-测试专用_全国政务信息一体化应用平台" , tagPriority: 10 }
  249. ]
  250. });
  251. </script>
  252. <style lang="less" scoped>
  253. .topicInfoBox {
  254. .inner {
  255. width: 1200px;
  256. margin: 0 auto;
  257. //信息头部
  258. .infoHead {
  259. height: 200px;
  260. padding: 65px 0 60px 40px;
  261. border-bottom: 1px solid rgba(0, 0, 0, 0.10);
  262. box-sizing: border-box;
  263. >.left {
  264. .userInfo {
  265. margin-right: 90px;
  266. .item {
  267. margin-top: -5px;
  268. margin-right: -5px;
  269. :deep(.el-badge__content.is-fixed) {
  270. position: absolute;
  271. right: calc(1px + var(--el-badge-size) / 2);
  272. top: 0;
  273. transform: translateY(-31%) translateX(79%);
  274. z-index: var(--el-index-normal);
  275. }
  276. img {
  277. width: 66px;
  278. height: 66px;
  279. vertical-align: middle;
  280. border-radius: 50%;
  281. }
  282. }
  283. span {
  284. margin-left: 15px;
  285. font-family: Microsoft YaHei, Microsoft YaHei;
  286. font-weight: 400;
  287. font-size: 18px;
  288. color: #333333;
  289. }
  290. }
  291. .headContent {
  292. h2 {
  293. width: 750px;
  294. height: 56px;
  295. line-height: 28px;
  296. display: -webkit-box;
  297. -webkit-box-orient: vertical;
  298. -webkit-line-clamp: 2;
  299. overflow: hidden;
  300. text-overflow: ellipsis;
  301. word-break: break-all;
  302. font-family: Microsoft YaHei, Microsoft YaHei;
  303. font-weight: bold;
  304. font-size: 20px;
  305. color: #333333;
  306. margin-bottom: 26px;
  307. }
  308. >p {
  309. font-family: Microsoft YaHei, Microsoft YaHei;
  310. font-weight: 400;
  311. font-size: 16px;
  312. color: #333333;
  313. button {
  314. width: 86px;
  315. height: 32px;
  316. background-color: #028e21;
  317. color: #fff;
  318. border: none;
  319. margin-left: 100px;
  320. }
  321. }
  322. }
  323. }
  324. >.right {
  325. position: relative;
  326. div {
  327. position: absolute;
  328. right: 0;
  329. top: 0;
  330. width: 71px;
  331. height: 32px;
  332. line-height: 32px;
  333. text-align: center;
  334. background-color: #d9f0d6;
  335. margin-bottom: 29px;
  336. font-family: Microsoft YaHei, Microsoft YaHei;
  337. font-weight: 400;
  338. font-size: 16px;
  339. color: #33B023;
  340. }
  341. .one {
  342. color: #FFAA33;
  343. background-color: #fbebd5;
  344. }
  345. .two {
  346. color: #33B023;
  347. background-color: #d5ecd2;
  348. }
  349. .three {
  350. color: #666;
  351. background-color: #ebebeb;
  352. }
  353. p {
  354. width: 150px;
  355. text-align: right;
  356. position: absolute;
  357. top: 62px;
  358. right: 0;
  359. }
  360. }
  361. }
  362. // 有详情信息
  363. .infoContent {
  364. width:1196px;
  365. overflow: hidden;
  366. padding: 40px 46px;
  367. font-family: Microsoft YaHei, Microsoft YaHei;
  368. font-size: 20px;
  369. line-height: 40px;
  370. box-sizing: border-box;
  371. div{
  372. word-wrap: break-word; /* 强制长单词或 URL 换行 */
  373. overflow-wrap: break-word; /* 现代推荐用法,等同于 word-wrap */
  374. white-space: pre-wrap; /* 保留空白字符并允许自动换行 */
  375. word-break: break-all; /* 强制在任意字符处换行 */
  376. }
  377. }
  378. .leftBottom::v-deep p{
  379. width:1200px;
  380. white-space: pre-wrap;
  381. }
  382. //没有详情信息
  383. .comment_empty,
  384. .infoContent1 {
  385. height: 300px;
  386. line-height: 260px;
  387. text-align: center;
  388. img {
  389. width: 78px;
  390. height: 78px;
  391. vertical-align: -25px;
  392. vertical-align: middle;
  393. margin-right: 20px;
  394. }
  395. span {
  396. font-family: Microsoft YaHei, Microsoft YaHei;
  397. font-weight: bold;
  398. font-size: 26px;
  399. color: #CCCCCC;
  400. }
  401. }
  402. //评论
  403. .comment {
  404. h3 {
  405. height: 100px;
  406. padding-top: 30px;
  407. box-sizing: border-box;
  408. border-bottom: 1px solid #E1E1E1;
  409. font-family: Microsoft YaHei, Microsoft YaHei;
  410. font-weight: 400;
  411. font-size: 22px;
  412. color: #000000;
  413. }
  414. .commentList {
  415. // height: 112px;
  416. border: 1px solid #E1E1E1;
  417. background-color: #fafafa;
  418. margin-top: 20px;
  419. padding: 30px 30px;
  420. box-sizing: border-box;
  421. display: flex;
  422. align-items: flex-start;
  423. justify-content: space-between;
  424. .left {
  425. width:400px;
  426. margin-right: 40px;
  427. // overflow: hidden;
  428. display: flex;
  429. justify-content: space-between;
  430. img {
  431. // float: left;
  432. width: 52px;
  433. height: 52px;
  434. border-radius: 50%;
  435. vertical-align: middle;
  436. margin-right: 15px;
  437. }
  438. span{
  439. // float: left;
  440. height: 52px;
  441. line-height: 22px;
  442. padding-top: 10px;
  443. }
  444. .name {
  445. width: 100px;
  446. font-family: Microsoft YaHei, Microsoft YaHei;
  447. font-weight: 400;
  448. font-size: 16px;
  449. color: #333333;
  450. margin-right: 30px;
  451. width: 100px;
  452. white-space: nowrap;
  453. overflow: hidden;
  454. text-overflow: ellipsis;
  455. display: block;
  456. }
  457. }
  458. .center {
  459. .context {
  460. width: 700px;
  461. margin-right: 40px;
  462. display: -webkit-box;
  463. -webkit-box-orient: vertical;
  464. -webkit-line-clamp: 2;
  465. overflow: hidden;
  466. text-overflow: ellipsis;
  467. word-break: break-all;
  468. font-family: Microsoft YaHei, Microsoft YaHei;
  469. font-weight: bold;
  470. font-size: 16px;
  471. color: #333333;
  472. }
  473. }
  474. .right {
  475. .time {
  476. display: block;
  477. width: 200px;
  478. font-family: Microsoft YaHei, Microsoft YaHei;
  479. font-weight: 400;
  480. font-size: 16px;
  481. color: #999999;
  482. margin-right: 30px;
  483. }
  484. span {
  485. font-family: Microsoft YaHei, Microsoft YaHei;
  486. font-weight: 400;
  487. font-size: 16px;
  488. color: #333333;
  489. }
  490. }
  491. }
  492. // .comment_empty {
  493. // height: 200px;
  494. // line-height: 200px;
  495. // text-align: center;
  496. // img {
  497. // width: 78px;
  498. // height: 78px;
  499. // vertical-align: -25px;
  500. // margin-right: 20px;
  501. // }
  502. // span {
  503. // font-family: Microsoft YaHei, Microsoft YaHei;
  504. // font-weight: bold;
  505. // font-size: 26px;
  506. // color: #CCCCCC;
  507. // }
  508. // }
  509. }
  510. }
  511. }
  512. //评论回复
  513. .message {
  514. width: 1200px;
  515. margin: 0 auto;
  516. padding: 0px 25px;
  517. box-sizing: border-box;
  518. height: 145px;
  519. line-height: 145px;
  520. background-color: #ecf5ee;
  521. .inner {
  522. .messageInput {
  523. width: 1000px;
  524. height: 67px;
  525. outline: none;
  526. border: 1px solid #E1E1E1;
  527. background-color: #fafafa;
  528. font-family: Microsoft YaHei, Microsoft YaHei;
  529. font-weight: 400;
  530. font-size: 18px;
  531. color: #666;
  532. padding: 0 20px;
  533. box-sizing: border-box;
  534. }
  535. .btn {
  536. width: 115px;
  537. height: 40px;
  538. border: none;
  539. background-color: #028e21;
  540. color: #fff;
  541. border-radius: 6px;
  542. margin-left: 36px;
  543. font-family: Microsoft YaHei, Microsoft YaHei;
  544. font-weight: 400;
  545. font-size: 16px;
  546. }
  547. }
  548. }
  549. //分页
  550. .paginationBox {
  551. display: flex;
  552. justify-content: center;
  553. margin-top: 60px;
  554. margin-bottom: 90px;
  555. // 鼠标移入后字体颜色
  556. :deep(.el-pagination:hover) {
  557. color: #139609;
  558. }
  559. :deep(.el-pagination.is-background .btn-next),
  560. :deep(.el-pagination.is-background .btn-prev) {
  561. width: 70px;
  562. height: 34px;
  563. margin: 0px 10px;
  564. border-radius: 4px;
  565. }
  566. :deep(.el-pagination.is-background .el-pager li) {
  567. margin: 0px 10px;
  568. width: 38px;
  569. height: 34px;
  570. border-radius: 4px;
  571. }
  572. :deep(.el-pagination.is-background .btn-next.is-active),
  573. :deep(.el-pagination.is-background .btn-prev.is-active),
  574. :deep(.el-pagination.is-background .el-pager li.is-active) {
  575. background-color: #028e21;
  576. color: #fff;
  577. }
  578. }
  579. </style>